{include file="common/header"/}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
              <div class="layui-card-header">{:lang('admin')}{:lang('list')}</div>
              <div class="layui-card-body">
                <div class="layui-row">
                    <form action="" class="layui-form">
                    <div class="layui-row layui-col-space10">
                      <div class="layui-col-md2 layui-col-xs4">
                        <input type="text" name="" id="keys" lay-verify="required" placeholder="请输入" class="layui-input">
                      </div>
                      <div class="layui-col-md2 layui-col-xs4">
                        <input type="button" id="searchBtn" name="submit" class="layui-btn" value="搜索">
                      </div>
                    </div>
                  </form>
                </div>
                <div class="layui-row">
                    <table class="layui-table" id="list" lay-filter="list"></table>
                </div>
              </div>
            </div>
        </div>
    </div>
</div>
{include file="common/footer"/}

<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-group">
        <a href="javascript:;" class="layui-btn layui-btn-sm" onclick="xadmin.open('{:lang(\'add\')}','{:url("add")}');"><i class="layui-icon layui-icon-add-circle"></i>{:lang('add')}</a>
    </div>
    
</script>


<script type="text/html" id="action">
    <div class="layui-btn-group">
        <a class="layui-btn layui-btn-xs" onclick="xadmin.open('{:lang('edit')}','{:url("edit")}?id={{d.id}}');">{:lang('edit')}</a>
        {{# if(d.id==1){ }}
        <a href="#" class="layui-btn layui-btn-xs layui-btn-disabled">{:lang('del')}</a>
        {{# }else{  }}
        <a data-href="{:url('del')}" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>
        {{# } }}
    </div>
</script>
<script type="text/html" id="status">
    {{# if(d.id==1){ }}
    <input data-href="{:url('state')}" type="checkbox" disabled name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" checked>
    {{# }else{  }}
    <input data-href="{:url('state')}" type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
    {{# } }}
</script>


<script>
var table;
var searchObj = {};

layui.use(['table','laydate'],function(){
  table = layui.table;
  table.render({
    elem: '#list'
    ,url:'{:url("index")}'
    ,method:'post'
    ,where:searchObj
    ,toolbar: '#toolbarDemo'
    ,defaultToolbar: []
    ,cellMinWidth: 60
    ,limit:20
    ,limits:[20,40,60,80,100]
    ,title: '{:lang("admin")}{:lang("list")}'
    ,id:'tableReload'
    ,cols: [[
        {field:'id', title: 'ID',fixed: true}
        ,{field:'username', title: '用户名'}
        ,{title: '{:lang("adminGroup")}', templet:function(d){
          return d.groups?d.groups.title:'';
        }}
        ,{field:'email', title: '{:lang("email")}'}
        ,{field:'mobile', title: '{:lang("mobile")}'}
        ,{field:'ip', title: '{:lang("ip")}',hide:true}
        ,{field:'status', title: '{:lang("status")}',toolbar: '#status'}
        ,{title:'操作',toolbar: '#action',align:"center"}
    ]]
    ,page: true
  });
  // 搜索
  $('#searchBtn').click(function(){
    searchObj['keys'] = $('#keys').val();
    table.reload('tableReload',{where:searchObj});
  }) 
});


</script>
